package com.si.anddos.search;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SearchResult implements Comparable<SearchResult> {
	static SimpleDateFormat FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private String name;
    private String extension;
    private String size;
    private String description;
    private String address;
    private String details;
    private Date added;
   
    
    
    public String getAdded() {
		return FORMATTER.format(added);
	}




	public void setAdded(String added) {
		 // pad the date if necessary
        while (!added.endsWith("00")){
        	added += "0";
        }
        try {
            this.added = FORMATTER.parse(added.trim());
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
	}




	public String getName() {
		return name;
	}




	public void setName(String name) {
		this.name = name;
	}




	public String getExtension() {
		return extension;
	}




	public void setExtension(String extension) {
		this.extension = extension;
	}




	public String getSize() {
		return size;
	}




	public void setSize(String size) {
		this.size = size;
	}




	public String getDescription() {
		return description;
	}




	public void setDescription(String description) {
		this.description = description;
	}




	public String getAddress() {
		return address;
	}




	public void setAddress(String address) {
		this.address = address;
	}




	public String getDetails() {
		return details;
	}




	public void setDetails(String details) {
		this.details = details;
	}




	// sort by date
    public int compareTo(SearchResult another) {
        if (another == null) return 1;
        // sort descending, most recent first
        return another.added.compareTo(added);
    }
}
